//
//  LSBookGridCell.m
//  LibraryStorm
//
//  Created by Enel@Lightning on 3/26/14.
//  Copyright (c) 2014 3ATeam. All rights reserved.
//

#import "LSBookGridCell.h"
#import "LSCustomCellBackground.h"
#import "UIImageView+AFNetworking.h"
#import "LSDownloadManager.h"

@implementation LSBookGridCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
- (void)awakeFromNib
{
    LSCustomCellBackground *backgroundView = [[LSCustomCellBackground alloc] initWithFrame:CGRectZero];
    self.selectedBackgroundView = backgroundView;
}

- (void)loadContentCell:(BookDetail *)book atIndexPath:(NSIndexPath *)indexPath
{
    if (book) {
        [self.coverImageView setImageWithURL:[NSURL URLWithString:book.coverImage] placeholderImage:BOOK_COVER_IMAGE];
        self.downloadIconImageView.hidden = YES;
        self.progressView.hidden = YES;
        if (book.downloadStatus.intValue == LSObjectDownloadCompleted && book.bookPath.length > 0) {
            self.downloadIconImageView.hidden = NO;
        }
    }
}
@end
